package cz.muni.fi.pa165.sportclubmanager.dao;

import cz.muni.fi.pa165.sportclubmanager.entity.AgeCategory;
import java.util.List;

/**
 * Interface for manipulating entities of type AgeCategory.
 *
 * @author Jan Bliznak 325348
 * @mail.muni.cz
 */
public interface AgeCategoryDAO {

    /**
     * Creates new entry for given age category in database. Value of name of
     * age category object is limited to 255 characters and condition
     * ageFrom&lt;ageTo must hold.
     *
     * @param ac age category to persist
     * @throws IllegalArgumentException when 1) ac is null or ac.name is null
     *                                  2) ac.id is not null, ie. it's already managed entity
     *                                  3) 0 &lte; ageFrom &lt; ageTo doesn't hold
     *                                  4) ac.name is longer than 255 chars
     */
    public void create(AgeCategory ac);

    /**
     * Updates entry for given age category. This means replace original values
     * of entry with given age category's id with new ones. Value of name of age
     * category object is limited to 255 characters and condition
     * ageFrom&lt;ageTo must hold.
     *
     * @param ac age category with id set
     * @throws IllegalArgumentException when 1) ac is null or ac.name is null
     *                                  2) ac.id is null
     *                                  3) 0 &lte; ageFrom &lt; ageTo doesn't hold
     *                                  4) ac.name is longer than 255 chars
     */
    public void update(AgeCategory ac);

    /**
     * Remove entry of given age category from database. At least id must be
     * set.
     *
     * @param ac age category with id set
     * @throws IllegalArgumentException when ac is null or ac.id is null
     */
    public void remove(AgeCategory ac);

    /**
     * Returns age category with given id. In case no such category exists this
     * method returns null.
     *
     * @param id non-null and non-negative id
     * @return age category or null if no such age category exists for given id
     * @throws IllegalArgumentException when id is null or id &lt; 0
     */
    public AgeCategory find(Long id);

    /**
     * Return age category which is the previous one to the one with given id.
     * Previous is meant as lexicographically less than (ageFrom,ageTo).
     *
     * @param id non-null and non-negative id
     * @return Age category just under the one with given id if it exists, null
     *         otherwise.
     * @throws IllegalArgumentException when id is null or id &lt; 0
     */
    public AgeCategory findClosestLower(Long id);

    /**
     * Returns list of all age categories stored in database.
     *
     * @return list of age categories
     */
    public List<AgeCategory> findAll();
}